# -*- mode: snippet -*-
# name: uniroot with integer
# key: uniroot_with_integer
# contributor : Shuguang Sun
# --
${1:already_visited} <- 0L

uniroot(
  function(${2:n}) {
    ${3:nf} <- floor($2)

    if (abs($1 - $3) < 0.5) {
      0
    } else {
      $1 <<- $3
      ${99:ret}
    }
  },
  interval = c(20, 1000)
)$root
